<template>
  <div class="recommend-login">
    <!-- 未登录 -->
    <div class="no-login" v-if="token === false">
      <p>登录网易云音乐，可以享受无限收藏的乐趣，并且无限同步到手机</p>
      <div class="button">
        <button @click="user">用户登录</button>
      </div>
    </div>
    <!-- 已登录 -->
    <div class="login" v-if="token === true">
      <img :src="this.$store.state.userDetail.avatarUrl" alt="" />
      <h1>欢迎，大傻逼</h1>
      <h1>{{ this.$store.state.userDetail.nickname }}</h1>
    </div>
  </div>
</template>

<script>
export default {
  created() {
    console.log(this.$store.state.userDetail)
  },
  computed: {
    token() {
      if (
        window.sessionStorage.getItem('token') ||
        window.sessionStorage.getItem('cookie')
      ) {
        return true
      }
      return false
    }
  },
  methods: {
    user() {
      this.$store.commit('editIsShow')
    }
  }
}
</script>

<style lang="scss" scoped>
.login {
  display: flex;
  flex-flow: column;
  align-items: center;
  img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
  }
}
.recommend-login {
  width: 100%;
  height: 126px;
  background: red;
  background: url('https://s2.music.126.net/style/web2/img/index/index.png?6f7122023fe4b0e7c59ac1d1226d1064')
    no-repeat 0 9999px;
  background-position: 0 0;
  p {
    color: #666;
    font-size: 12px;
    margin: 0 22.5px;
    padding: 16px 0;
    width: 205px;
    height: 76px;
  }
  .button {
    width: 100%;
    display: flex;
    justify-content: center;
    button {
      width: 100px;
      height: 31px;
      color: #fff;
      text-shadow: 0 1px 0 #8a060b;
      background: #e4242b;
      border: none;

      &:hover {
        cursor: pointer;
      }
    }
  }
}
</style>
